First-Class Functions in an Imperative World

نویسنده

  • Roberto Ierusalimschy
چکیده

First-class functions are a hallmark of functional languages, but they are a useful concept in imperative languages, too. Even ANSI C offers a restricted form of first-class functions (in the form of pointers to functions), and several more recent imperative languages, such as Python 3, Go, Lua, and Swift, offer first-class, anonymous functions with lexical scoping. In most imperative languages, however, first-class functions are an advanced feature used by seasoned programmers. Lua, by contrast, uses first-class functions as a building block of the language. Lua programmers regularly benefit from diverse properties of its functions for routine constructions such as exception handling, module definitions, object-oriented programming, and iterators. Moreover, first-class functions play a central role in the API between Lua and C. In this paper, we present some aspects of Lua that were designed with first-class functions in mind, in particular its module system, exception handling, iterators, facilities for object-oriented programming, and the API between C and Lua. We also discuss how those different aspects of Lua use different properties of first-class functions to achieve two important goals in the design of Lua, namely small size and embeddability (its easiness of interfacing with other languages).

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

An Analysis of the Missions and Goals, Content, Tools, and Functions of Faculty development Centers in World-Class Universities: A Comparative Comparison

Introduction: The purpose of this study was to identify the missions and goals, content, tools, and functions of faculty development centers in world-class universities. Method: This study was conducted using qualitative approach and comparative comparison method and content analysis. Data were collected using the Times 2020 ranking site and sites of centers at world-class universities rated be...

متن کامل

Coefficient Bounds for Analytic bi-Bazileviv{c} Functions Related to Shell-like Curves Connected with Fibonacci Numbers

In this paper, we define and investigate a new class of bi-Bazilevic functions related to shell-like curves connected with Fibonacci numbers.  Furthermore, we find estimates of first two coefficients of functions belonging to this class. Also, we give the Fekete-Szegoinequality for this function class.

متن کامل

Descriptive and Relative Completeness of Logics for Higher-Order Functions

This paper establishes a strong completeness property of compositional program logics for pure and imperative higher-order functions introduced in [2, 15–18]. This property, called descriptive completeness, says that for each program there is an assertion fully describing the former’s behaviour up to the standard observational semantics. This formula is inductively calculable from the program t...

متن کامل

Some fixed point theorems for $C$-class functions in $b$-metric spaces

In this paper, via $C$-class functions, as a new class of functions, a fixed theorem in complete $b$-metric spaces is presented. Moreover, we study some results, which are direct consequences of the main results. In addition, as an application, the existence of a solution of an integral equation is given.

متن کامل

SOLVING NONLINEAR TWO-DIMENSIONAL VOLTERRA INTEGRAL EQUATIONS OF THE FIRST-KIND USING BIVARIATE SHIFTED LEGENDRE FUNCTIONS

In this paper, a method for finding an approximate solution of a class of two-dimensional nonlinear Volterra integral equations of the first-kind is proposed. This problem is transformedto a nonlinear two-dimensional Volterra integral equation of the second-kind. The properties ofthe bivariate shifted Legendre functions are presented. The operational matrices of integrationtogether with the produ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:
  • J. UCS

دوره 23  شماره 

صفحات  -

تاریخ انتشار 2017